package com.ght.springboot.rabbitmq.customer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: haitao.gao
 * @create: 2019-01-10 17:29
 **/
//@Slf4j
//@Component
//@RabbitListener(queues = "test-queue1-routing")
public class Test2QueueCustomer extends BaseQueueCustomer{

    public Test2QueueCustomer(@Qualifier("deathLetterQueue") Queue queue) {
        super(queue);
    }

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {

        try {
            System.out.print("\n"+"测试死信箱队列：" + new String(message.getBody()) +"\n");
            channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);

        }catch (Exception e){

        }
    }

}
